package com.example.demo.serviceimp;

import com.example.demo.entity.Plan;
import com.example.demo.mapper.PlanMapper;
import com.example.demo.service.PlanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class PlanServiceImp implements PlanService {

    @Resource
    private PlanMapper planMapper;

    /**
     * 查询进度表中章节记录
     * */
    @Override
    public List<Plan> selplan(Integer uid) {
        return planMapper.selplan(uid);
    }

    /**
     * 提交进度
     * */
    @Override
    public int inplan(Integer uid, Integer tpid, Integer cnode,Integer score,Integer tscore) {
        return planMapper.inplan(uid,tpid,cnode,score,tscore);
    }

    /**
     * 查询NODE数据量，若两表count相等，则开放id=count
     * */
    @Override
    public int selpnode(Integer cnode,Integer uid) {
        return planMapper.selpnode(cnode,uid);
    }

    @Override
    public int selcnode(Integer cnode) {
        return planMapper.selcnode(cnode);
    }

    /**
     * 查询进度表中node最大值用以判断考试进度
     * */
    @Override
    public int selmnode(Integer uid) {
        return planMapper.selmnode(uid);
    }

    /**
     * 查询node最大值对应的chapter_id
     * */
    @Override
    public int selmnodecpid(Integer cnode) {
        return planMapper.selmnodecpid(cnode);
    }

    /**
     * 开启考试
     * */
    @Override
    public int uplan(Integer uid) {
        return planMapper.uplan(uid);
    }

    /**
     * 进入下一章节,添加临时进度数据
     * */
    @Override
    public int incnodemax(Integer uid, Integer cnode) {
        return planMapper.incnodemax(uid,cnode);
    }

    @Override
    public List<Map> selstandard(Integer uid, Integer cnode) {
        return planMapper.selstandard(uid, cnode);
    }

    /**
     * 查询是否存在临时进度数据
     * */
    @Override
    public List<Plan> sellsdata(Integer uid, Integer cnode) {
        return planMapper.sellsdata(uid,cnode);
    }

    /**
     * 删除临时进度数据
     * */
    @Override
    public int delucnode(Integer uid, Integer cnode) {
        return planMapper.delucnode(uid,cnode);
    }

    /**
     * 查询成绩
     * */
    @Override
    public Plan selscore(Integer cid, Integer uid) {
        return planMapper.selscore(cid, uid);
    }

    /**
     * 查询排行
     * @param tid
     * @return
     */
    @Override
    public List selranking(Integer tid) {//当前用户当前章节排名
        return planMapper.selranking(tid);
    }

    @Override
    public List selcount(Integer tid) {//分数对应的人数
        return planMapper.selcount(tid);
    }

    @Override
    public List selminscore(Integer tid) {//最低分
        return planMapper.selminscore(tid);
    }

    @Override
    public List selmaxscore(Integer tid) {//最高分
        return planMapper.selmaxscore(tid);
    }

    @Override
    public int delplan(Integer uid, Integer tpid) {
        return planMapper.delplan(uid, tpid);
    }

    @Override
    public int delrec(Integer uid, Integer tpid) {
        return planMapper.delrec(uid, tpid);
    }

}
